var e, t, o, n, a, s, c, l = 0, r = 0;

Page({
    data: {
        startPoint: [ 0, 0 ],
        num: 90.0001,
        drp: 2,
        src: "",
        show: !1,
        cX: "",
        cY: "",
        stv: {
            offsetX: 250,
            offsetY: 0,
            zoom: !1,
            distance: 0,
            scale: 1
        },
        phoneState: !1,
        loading: !1,
        canvasw: 0,
        canvash: 0,
        showzhen: !1
    },
    onLoad: function(e) {
        var t = this;
        console.log("onload"), wx.getSystemInfo({
            success: function(e) {
                l = e.windowWidth, r = e.windowHeight;
            }
        }), this.setData({
            canvasWidth: l,
            canvasHeight: r
        });
        var o = wx.createSelectorQuery();
        setTimeout(function() {
            o.select("#nav").boundingClientRect(function(e) {
                console.log(e), "" === e.bottom && 0 === e.bottom || (wx.setStorageSync("leftX", e.left), 
                wx.setStorageSync("topY", e.top + e.height / 2), t.setData({
                    showzhen: !0
                }));
            }).exec();
        }, 200);
    },
    drawline: function() {
        var t = "", o = "";
        e = wx.createCanvasContext("myCanvas", this), n = wx.createCanvasContext("myCanvasClose", this), 
        new Promise(function(e, n) {
            wx.createSelectorQuery().select("#nav").boundingClientRect(function(e) {
                console.log(e), t = e.left, o = e.top + e.height / 2;
            }).exec();
        }).then(function() {
            e.beginPath(), e.lineWidth = 1, e.strokeStyle = "#07c160", e.arc(t + 280, o, 10, 0, 2 * Math.PI, !1), 
            e.stroke(), e.setStrokeStyle("#07c160"), e.moveTo(t, o), e.lineTo(t + 280, o), e.stroke(), 
            e.draw(), n.beginPath(), n.lineWidth = 1, n.strokeStyle = "#07c160", n.arc(t + 280, o + 5, 10, 0, 2 * Math.PI, !1), 
            n.stroke(), n.setStrokeStyle("#07c160"), n.moveTo(t, o), n.lineTo(t + 280, o), n.stroke(), 
            n.draw();
        });
    },
    canvasIdErrorCallback: function(e) {
        console.log(e);
    },
    EventHandleStart: function(e) {
        e.touches[0].x, e.touches[0].y;
        wx.getStorageSync("leftX");
    },
    EventHandleStartclose: function(e) {
        a = e.touches[0].x, e.touches[0].y;
        var t = wx.getStorageSync("leftX");
        if (!(a < t)) {
            var o = wx.getStorageSync("topY");
            if (s = e.changedTouches[0].x, c = e.changedTouches[0].y, !(s < t)) {
                var l = (s - t) / Math.abs(c - o), r = (Math.atan(l) / (Math.PI / 180)).toFixed(2);
                if (c > o) {
                    var i = (180 - r).toFixed(2);
                    this.setData({
                        num: i
                    });
                } else this.setData({
                    num: r
                });
                n.beginPath(), n.lineWidth = 1, n.strokeStyle = "#07c160", n.arc(s, c, 10, 0, 2 * Math.PI, !1), 
                n.stroke(), n.beginPath(), n.setStrokeStyle("#07c160"), n.moveTo(t, o), n.lineTo(s, c), 
                n.stroke(), n.draw();
            }
        }
    },
    EventHandle: function(n) {
        console.log("关闭状态的结束执行");
        var a = wx.getStorageSync("leftX"), s = wx.getStorageSync("topY");
        if (t = n.changedTouches[0].x, o = n.changedTouches[0].y, !(t < a)) {
            var c = (t - a) / Math.abs(o - s), l = (Math.atan(c) / (Math.PI / 180)).toFixed(2);
            if (o > s) {
                var r = (180 - l).toFixed(2);
                console.log("》90"), this.setData({
                    num: r
                });
            } else console.log("<90"), this.setData({
                num: l
            });
            e.draw(), e.beginPath(), e.lineWidth = 1, e.strokeStyle = "#07c160", e.arc(t, o, 10, 0, 2 * Math.PI, !1), 
            e.stroke(), e.beginPath(), e.setStrokeStyle("#07c160"), e.moveTo(a, s), e.lineTo(t, o), 
            e.stroke(), e.draw();
        }
    },
    EventHandleclose: function(e) {
        console.log(e), console.log("打开状态的结束执行");
        var t = wx.getStorageSync("leftX"), o = wx.getStorageSync("topY");
        if (console.log(t), console.log(o), s = e.changedTouches[0].x, c = e.changedTouches[0].y, 
        console.log(s), console.log(t), console.log(s < t), !(s < t)) {
            var a = (s - t) / Math.abs(c - o);
            console.log(a);
            var l = (Math.atan(a) / (Math.PI / 180)).toFixed(2);
            if (console.log(l), c > o) {
                var r = (180 - l).toFixed(2);
                console.log("》90"), this.setData({
                    num: r
                });
            } else console.log("<90"), this.setData({
                num: l
            });
            n.draw(), n.beginPath(), n.lineWidth = 1, n.strokeStyle = "#07c160", n.arc(s, c, 10, 0, 2 * Math.PI, !1), 
            n.stroke(), n.beginPath(), n.setStrokeStyle("#07c160"), n.moveTo(t, o), n.lineTo(s, c), 
            n.stroke(), n.draw();
        }
    },
    EventHandleMove: function(n) {
        console.log(n), console.log("结束");
        var a = wx.getStorageSync("leftX"), s = wx.getStorageSync("topY");
        if (t = n.changedTouches[0].x, o = n.changedTouches[0].y, console.log(t), !(t < a)) {
            var c = (t - a) / Math.abs(o - s);
            console.log(c);
            var l = (Math.atan(c) / (Math.PI / 180)).toFixed(2);
            if (o > s) {
                console.log("》90");
                var r = (180 - l).toFixed(2);
                console.log(r), this.setData({
                    num: r
                });
            } else console.log("<90"), this.setData({
                num: l
            });
            e.beginPath(), e.setStrokeStyle("#07c160"), e.moveTo(a, s), e.lineTo(t, o), e.stroke(), 
            e.draw(), e.beginPath(), e.lineWidth = 1, e.strokeStyle = "#07c160", e.arc(t, o, 10, 0, 2 * Math.PI, !1), 
            e.stroke();
        }
    },
    EventHandleMoveclose: function(e) {
        var t = wx.getStorageSync("leftX"), o = wx.getStorageSync("topY");
        if (s = e.changedTouches[0].x, c = e.changedTouches[0].y, console.log(s), !(s < t)) {
            var a = (s - t) / Math.abs(c - o);
            console.log(a);
            var l = (Math.atan(a) / (Math.PI / 180)).toFixed(2);
            if (c > o) {
                console.log("》90");
                var r = (180 - l).toFixed(2);
                console.log(r), this.setData({
                    num: r
                });
            } else console.log("<90"), this.setData({
                num: l
            });
            n.beginPath(), n.setStrokeStyle("#07c160"), n.moveTo(t, o), n.lineTo(s, c), n.stroke(), 
            n.draw(), n.beginPath(), n.lineWidth = 1, n.strokeStyle = "#07c160", n.arc(s, c, 10, 0, 2 * Math.PI, !1), 
            n.stroke();
        }
    },
    onReady: function() {
        this.setData({
            num: this.data.num.toFixed(2)
        });
    },
    clickCanvas: function(t) {
        wx.createSelectorQuery();
        var o = wx.getStorageSync("leftX"), n = wx.getStorageSync("topY");
        e.beginPath(), e.setStrokeStyle("#07c160"), e.moveTo(o, n), e.lineTo(t.touches[0].x, t.touches[0].y), 
        e.stroke(), e.draw();
    },
    openPhoto: function() {
        this.setData({
            phoneState: !this.data.phoneState,
            num: 90.0001.toFixed(2)
        });
        var t = wx.getStorageSync("leftX"), o = wx.getStorageSync("topY");
        e = wx.createCanvasContext("myCanvas", this), n = wx.createCanvasContext("myCanvasClose", this), 
        e.beginPath(), e.lineWidth = 1, e.strokeStyle = "#07c160", e.arc(t + 280, o, 10, 0, 2 * Math.PI, !1), 
        e.stroke(), e.setStrokeStyle("#07c160"), e.moveTo(t, o), e.lineTo(t + 280, o), e.stroke(), 
        e.draw(), n.beginPath(), n.lineWidth = 1, n.strokeStyle = "#07c160", n.arc(t + 280, o, 10, 0, 2 * Math.PI, !1), 
        n.stroke(), n.setStrokeStyle("#07c160"), n.moveTo(t, o), n.lineTo(t + 280, o), n.stroke(), 
        n.draw();
    },
    closePhoto: function() {
        this.setData({
            phoneState: !1,
            num: 90.0001.toFixed(2)
        });
        var t = wx.getStorageSync("leftX"), o = wx.getStorageSync("topY");
        (e = wx.createCanvasContext("myCanvas", this)).beginPath(), e.lineWidth = 2, e.strokeStyle = "#07c160", 
        console.log("绘制"), e.arc(t + 280, o + 5, 10, 0, 2 * Math.PI, !1), e.stroke(), e.setStrokeStyle("#07c160"), 
        e.moveTo(t, o + 5), e.lineTo(t + 280, o + 5), e.stroke(), e.draw();
    },
    touchChange: function(e) {
        console.log(e), console.log("触碰执行");
    },
    cancelBtn: function() {
        this.setData({
            show: !1
        });
    },
    change: function(e) {
        console.log(e);
    },
    onShow: function() {
        this.drawline();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareTimeline: function() {
        return {
            title: "给大家推荐一个能在手机上用的尺子：锤子工具人。",
            imageUrl: "http://file.scjrh.net/hammer/logo.png"
        };
    },
    onShareAppMessage: function(e) {
        var t = {
            title: "给你推荐一个量角器小工具",
            success: function(e) {
                e.errMsg;
            },
            fail: function() {
                "shareAppMessage:fail cancel" == res.errMsg || res.errMsg;
            }
        };
        return e.from, t;
    }
});